﻿Public Class frmAlmacen

    Dim ds As DataSet = Nothing

    Sub New(ds As DataSet)

        ' Llamada necesaria para el diseñador.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        Me.ds = ds
    End Sub

    Private Sub frmAlmacen_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        cargarAlmacen()
    End Sub

    Sub cargarAlmacen()
        dgvAlmacen.DataSource = ds.Tables(0)

        If ds.Tables(0).Rows.Count <> 0 Then
            dgvAlmacen.Rows(0).Selected = False
        End If
    End Sub

    Private Sub dgvAlmacen_CellClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvAlmacen.CellClick
        Dim f As Integer = e.RowIndex

        If f > -1 Then
            frmMenu.formDocumento.txtAlmacen.Text = dgvAlmacen.Item("Column1", f).Value
            DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub dgvAlmacen_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles dgvAlmacen.KeyDown
        If e.KeyValue = Keys.Enter Then
            frmMenu.formDocumento.txtAlmacen.Text = dgvAlmacen.Rows(dgvAlmacen.CurrentRow.Index).Cells("Column1").Value
            DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

End Class